<?php

namespace App\Services;

use App\Models\BannerModel;

class BannerService extends BaseService {

    public function list(){
        $query = BannerModel::query();

        $query->where("id", 1);
        $res = $query->first();

        return $res ? $res->toArray() : [];
    }

    public function getList(){
        $list = $this->list();
        if (empty($list)){
            return [];
        }
        return $list['images'];
    }

    public function save($data) {
        $res = BannerModel::find(1);
        if (empty($res)) {
            $model = new BannerModel();
            $model->images = $data;
            $model->save();
        }else{
            $res->images = $data;
            $res->save();
        }
        return true;
    }
}